
class PageContent{
  constructor({info={},request={},response={},scripts={},extend={}} = {}){
    this.info = info
    this.request = request
    this.response = response
    this.scripts = scripts
    this.extend = extend
  }
}

 class PageContentInfo {
  from = 'runapi'
  type = 'api'
  title = ''
  description = ''
  method = 'post'
  url = ''
  remark = ''
  apiStatus = ''
  constructor(obj) {
    if (typeof obj === 'object' && obj) {
      this.from = obj.from || 'runapi'
      this.type = obj.type || 'api'
      this.title = obj.title || ''
      this.description = obj.description || ''
      this.method = obj.method || 'post'
      this.url = obj.url || ''
      this.remark = obj.remark || ''
      this.apiStatus = obj.apiStatus || ''
    }
  }
}

 class PageContentRequest {
  params = {
    mode: '',
    urlencoded: [],
    formdata: [],
    json: '',
    jsonDesc: []
  }
  headers = {}
  cookies = {}
  auth = []
  query = []
  pathVariable = []

  constructor(obj) {
    if (obj) {
      this.params = Object.assign(this.params, obj.params)
      this.headers = Object.assign(this.params, obj.headers || {})
      this.cookies = Object.assign(this.params, obj.cookies || {})
      this.auth = obj.auth || []
      this.query = obj.query || []
      this.pathVariable = obj.pathVariable || []
    }
  }
}

 class PageContentResponse {
  responseText = ''
  responseOriginal = ''
  responseHeader = {}
  responseStatus = 0
  responseExample = ''
  responseParamsDesc = []
  responseFailExample = "{\n    \"status\": 100002,\n    \"message\": \"接口处理失败\",\n    \"data\": 0\n}"
  responseFailParamsDesc = [
    {
      "name": "status",
      "type": "number",
      "remark": "错误码"
    },
    {
      "name": "message",
      "type": "string",
      "remark": "接口信息描述"
    },
    {
      "name": "data",
      "type": "object",
      "remark": "返回数据"
    }
  ]
  remark = ''

  constructor(responseExample, responseParamsDesc) {
    this.responseExample = responseExample
    this.responseParamsDesc = responseParamsDesc
  }
}

 class PageContentScripts {
  pre = ''
  post = ''
}
 class PageContentExtend {

}

 class updateByApiParams {
  api_key = ''
  api_token = ''
  cat_name = ''
  page_title = ''
  s_number = ''
  constructor(obj) {
    if (obj) {
      this.api_key = obj.apiKey
      this.api_token = obj.ApiToken
      this.cat_name = obj.catName
      this.page_title = obj.pageTitle
      this.page_content = obj.pageContent
      this.s_number = obj.sNumber
    }

  }
}

module.exports = {
  PageContentInfo,
  PageContentRequest,
  PageContentResponse,
  PageContentScripts,
  PageContentExtend,
  updateByApiParams,
  PageContent
}